home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / internet / ghostzilla / ghsetup.exe / res / builtin / checkboxBindings.xml < prev    next >
Encoding:
Extensible Markup Language  |  2002-04-09  |  2.0 KB  |  69 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings id="checkboxBindings"
  4.    xmlns="http://www.mozilla.org/xbl"
  5.    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  6.  
  7.   <binding id="checkbox" display="xul:button">
  8.     <implementation>
  9.       <property name="checked">
  10.         <getter>
  11.         var image = this.getElementByAttribute("cbattr", "image");
  12.         if (image) {
  13.           return image.hasAttribute("checked");
  14.         }
  15.         return false;
  16.         </getter>
  17.         <setter> 
  18.         var image = this.getElementByAttribute("cbattr", "image");
  19.         if (image) {
  20.           if (val)
  21.             image.setAttribute("checked", "true");
  22.           else image.removeAttribute("checked");
  23.         }
  24.         </setter>
  25.       </property>
  26.       
  27.       <!-- Internal Implementation Methods -->
  28.       <method name="getElementByAttribute">
  29.         <parameter name="aAttributeName"/>
  30.         <parameter name="aAttributeValue"/>
  31.         <body>
  32.         <![CDATA[
  33.           var anonymousNodes = document.getAnonymousNodes(this);
  34.           for (var i = 0; i < anonymousNodes.length; ++i)
  35.             return this.recursiveAttributeSearch(anonymousNodes[i], aAttributeName, aAttributeValue);
  36.           return null;
  37.         ]]> 
  38.         </body>
  39.       </method>
  40.       <method name="recursiveAttributeSearch">
  41.         <parameter name="aNode"/>
  42.         <parameter name="aAttributeName"/>
  43.         <parameter name="aAttributeValue"/>
  44.         <body>
  45.         <![CDATA[
  46.           if (aNode) {
  47.             if (aNode.getAttribute(aAttributeName) == aAttributeValue)
  48.               return aNode;
  49.               
  50.             for (var i = 0; i < aNode.childNodes.length; ++i)
  51.               return this.recursiveAttributeSearch(aNode.childNodes[i], aAttributeName, aAttributeValue);
  52.           } 
  53.           return null;
  54.         ]]>
  55.         </body>
  56.       </method>
  57.     </implementation>
  58.     <handlers>
  59.       <handler event="command">
  60.       <![CDATA[
  61.         this.checked = !this.checked;
  62.       ]]>
  63.       </handler>
  64.     </handlers>
  65.   </binding>
  66.   
  67. </bindings>
  68.  
  69.